home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / RKMLibsPrgs / graphics_libraries / text / Suits8.asm < prev   
Assembly Source File  |  1992-09-03  |  8KB  |  134 lines

  1. * A sparse (but complete) sample font.
  2. *
  3. * 1.  Assemble this file (assumed to have been saved as "suits8.asm"). For example, if you have the
  4. * CAPE 680x0 assembler, and you have assigned "include:" to the directory containing your include
  5. * files, use:
  6. *          CAsm -a "suits8.asm" -o "suits8.o" -i "include:"
  7. *
  8. *     Link "suits8.o".  For example, if you have Lattice, use:
  9. *          BLink from "suits8.o" to "suits8"
  10. *
  11. * 2.  Create the subdirectory "Fonts:suits".  Copy the file "suits8" (created in step 1)
  12. *     to "Fonts:suits/8".
  13. *
  14. * 3.  Create a font contents file for the font.  You can do this by two methods:
  15. *
  16. *   a. Run the program "System/FixFonts" which will create the file "Fonts:suits.font"
  17. *      automatically.
  18. *   b. Use the NewFontContents() call in the diskfont library to create a FontContentsHeader
  19. *      structure, which can be saved in the Fonts: directory as "suits.font".   This is essentially
  20. *      what FixFonts does.
  21. *
  22. * The next word contains the font YSize; in this case, 0x0008.
  23. *
  24. * The next byte contains the font Flags, in this case 0x00.
  25. *
  26. * The last byte contains the font characteristics, in this case 0x60.  This says it is a disk-based
  27. * font (bit 1 set) and the font has been removed (bit 7 set), saying that the font is not currently
  28. * resident.
  29. *
  30. * Summary of suits.font file:
  31. *
  32. * Name: fch_FileID fch_NumEntries fc_FileName     fc_YSize fc_Flags fc_Style
  33. * Size: word       word     MAXFONTPATH bytes word     byte     byte
  34. * Hex:  0f00       0001     73756974732F3800  0008     00       60
  35. * ASCII:            s u i t s / 8 \0
  36. *
  37. * The correct length of a font file may be calculated with this formula:
  38. * length = ((number of font contents entries) * (MAXFONTPATH+4)) + 4. In this case (one entry),
  39. * this becomes (MAXFONTPATH + 8) or 264.
  40. *
  41. * To try out this example font, do the following.  Use the Fonts Preferences editor or a
  42. * program that allows the user to select fonts.  Choose the "suits" font in size 8.
  43. * This example font defines ASCII characters 'a' 'b' 'c' and 'd' only. All other characters
  44. * map to a rectangle, meaning "character unknown".
  45.  
  46.     INCLUDE  "exec/types.i"
  47.     INCLUDE  "exec/nodes.i"
  48.     INCLUDE  "libraries/diskfont.i"
  49.  
  50.     MOVEQ     #-1,D0      ; Provide an easy exit in case this file is
  51.     RTS                   ; "Run" instead of merely loaded.
  52.  
  53.     DC.L      0           ; ln_Succ     * These five entries comprise a Node structure,
  54.     DC.L      0           ; ln_Pred     * used by the system to link disk fonts into a
  55.     DC.B      NT_FONT     ; ln_Type     * list.  See the definition of the "DiskFontHeader"
  56.     DC.B      0           ; ln_Pri      * structure in the "libraries/diskfont.i" include
  57.     DC.L      fontName    ; ln_Name     * file for more information.
  58.  
  59.     DC.W      DFH_ID      ; FileID
  60.     DC.W      1           ; Revision
  61.     DC.L      0           ; Segment
  62.  
  63. * The next MAXFONTNAME bytes are a placeholder.  The name of the font contents file (e.g.
  64. * "suits.font") will be copied here after this font descriptor is LoadSeg-ed into memory.  The Name
  65. * field could have been left blank, but inserting the font name and size (or style) allows one to
  66. * tell something about the font by using "Type OPT H" on the file.
  67.  
  68. fontName:
  69.     DC.B      "suits8"    ; Name
  70.  
  71. * If your assembler needs an absolute value in place of the "length" variable, simply count the
  72. * number of characters in Name and use that.
  73.  
  74. length  EQU     *-fontName              ; Assembler calculates Name's length.
  75.         DCB.B   MAXFONTNAME-length,0    ; Padding of null characters.
  76.  
  77. font:
  78.     DC.L    0               ; ln_Succ       * The rest of the information is a TextFont
  79.     DC.L    0               ; ln_Pred       * structure.  See the "graphics/text.i" include
  80.     DC.B    NT_FONT         ; ln_Type       * file for more information.
  81.     DC.B    0               ; ln_Pri
  82.     DC.L    fontName        ; ln_Name
  83.     DC.L    0               ; mn_ReplyPort
  84.     DC.W    0               ; (Reserved for 1.4 system use.)
  85.     DC.W    8               ; tf_YSize
  86.     DC.B    0               ; tf_Style
  87.     DC.B    FPF_DESIGNED!FPF_PROPORTIONAL!FPF_DISKFONT ; tf_Flags
  88.     DC.W    14              ; tf_XSize
  89.     DC.W    6               ; tf_Baseline  <----* tf_Baseline must be no greater than
  90.     DC.W    1               ; tf_BoldSmear      * tf_YSize-1, otherwise algorithmically-
  91.     DC.W    0               ; tf_Accessors      * generated styles (italic in particular)
  92.     DC.B    97              ; tf_LoChar         * can corrupt system memory.
  93.     DC.B    100             ; tf_HiChar
  94.     DC.L    fontData        ; tf_CharData
  95.     DC.W    8               ; tf_Modulo  <- * add this to the data pointer to go from from
  96.                             ;               * one row of a character to the next row of it.
  97.     DC.L    fontLoc         ; tf_CharLoc <---------------- * bit position in the font data
  98.     DC.L    fontSpace       ; tf_CharSpace                 * at which the character begins.
  99.     DC.L    fontKern        ; tf_CharKern
  100.  
  101. * The four characters of this font define the four playing-card suit symbols.  The heart, club,
  102. * diamond, and spade map to the lower-case ASCII characters 'a', 'b', 'c', and 'd' respectively The
  103. * fifth entry in the table is the character to be output when there is no entry defined in the
  104. * character set for the requested ASCII value.  Font data is bit-packed edge to edge to save space.
  105.  
  106. fontData:                             ;   97 (a)       98 (b)       99 (c)   100 (d)      255
  107.     DC.W  $071C0,$08040,$070FF,$0F000 ; <        X        X    X        X        >
  108.     DC.W  $0FBE3,$0E0E0,$0F8C0,$03000 ;  .@@@...@@@.  .....@.....  ...@...  ....@@@....  @@@@@@@@@@@@
  109.     DC.W  $07FCF,$0F9F3,$026C0,$03000 ;  @@@@@.@@@@@  ...@@@@@...  ..@@@..  ...@@@@@...  @@........@@
  110.     DC.W  $03F9F,$0FFFF,$0FFC0,$03000 ;  .@@@@@@@@@.  .@@@@@@@@@.  .@@@@@.  .@@..@..@@.  @@........@@
  111.     DC.W  $01F0E,$0B9F3,$026C0,$03000 ;  ..@@@@@@@..  @@@@@@@@@@@  @@@@@@@  @@@@@@@@@@@  @@........@@
  112.     DC.W  $00E00,$080E0,$020C0,$03000 ;  ...@@@@@...  .@@@.@.@@@.  .@@@@@.  .@@..@..@@.  @@........@@
  113.     DC.W  $00403,$0E040,$0F8FF,$0F000 ;  ....@@@....  .....@.....  ..@@@..  .....@.....  @@........@@
  114.     DC.W  $00000,$00000,$00000,$00000 ;  .....@.....  ...@@@@@...  ...@...  ...@@@@@...  @@@@@@@@@@@@
  115.     DC.W  $00000,$00000,$00000,$00000 ;  ...........  ...........  .......  ...........  ............
  116.  
  117. fontLoc:                 ; The fontLoc information is used to "unpack" the fontData. Each
  118.     DC.L    $00000000B   ; pair of words specifies how the characters are bit-packed.  For
  119.     DC.L    $0000B000B   ; example, the first character starts at bit position 0x0000, and
  120.     DC.L    $000160007   ; is 0x000B (11) bits wide.  The second character starts at bit
  121.     DC.L    $0001D000B   ; position 0x000B and is 0x000B bits wide, and so on.  This tells
  122.     DC.L    $00028000C   ; the font handler how to unpack the bits from the array.
  123.  
  124. fontSpace:                        ; fontSpace array:  Use a space this wide to contain this
  125.     DC.W    000012,000012         ; character when it is printed.  For reverse-path fonts
  126.     DC.W    000008,000012,000013  ;  these values would be small or negative.
  127.  
  128. fontKern:                         ; fontKern array:  Place a space this wide after the
  129.     DC.W    000001,000001         ; corresponding character to separate it from the following
  130.     DC.W    000001,000001,000001  ; character.  For reverse-path fonts these values would be large
  131.                                   ; negative numbers, approximately the width of the characters.
  132. fontEnd:
  133.     END
  134.